<!doctype html>
<html>
<head>
    <meta charset="UTF-8">
    <title>后台管理</title>
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/static/admin/css/common.css"/>
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/static/admin/css/main.css"/>
    <script type="text/javascript" src="__PUBLIC__/static/admin/js/libs/modernizr.min.js"></script>


    <!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
    <script src="http://cdn.bootcss.com/jquery/1.11.1/jquery.min.js"></script>

    <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
    <script src="http://cdn.bootcss.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>
    <link type="text/css" href="<%=basePath%>/resources/css/jquery-ui/jquery-ui.css" rel="stylesheet" />
    <script type="text/javascript" src="<%=basePath%>/resources/js/jquery/jquery-1.11.3.min.js"></script>
    <script type="text/javascript" src="<%=basePath%>/resources/js/jquery-ui/jquery-ui.js"></script>
</head>
<style type="text/css">
    ul.pagination  li{
        float: left;
    }
    div.list-page{
        width: 400px;
        margin: 0 auto;
        text-align: center;
    }
</style>
<body>
    {include file="Public/top" /}
    <div class="container clearfix">
        {include file="Public/left" /}
        <!--/sidebar-->
        <div class="main-wrap">

            <div class="crumb-wrap">
                <div class="crumb-list"><i class="icon-font"></i><a href="{:url('admin/index/index')}">首页</a><span class="crumb-step">&gt;</span><span class="crumb-name">用户管理</span></div>
            </div>
            <div class="result-wrap">
                <form name="myform" id="myform" method="post" action="{:url('limit')}">
                    <div class="result-title">
                        <div class="result-list" >
                            {if condition="$articleid eq ''"} 
                            <a href="{:url('add')}"><i class="icon-font"></i>新增用户</a>
                            <a href="{:url('join')}"><i class="icon-font"></i>导入用户</a>
                            <a href="{:url('out')}"><i class="icon-font"></i>导出用户</a>
                            {else}
                            请选择需要指定的用户：

                            {/if}
                        </div>
                    </div>
                    <div class="result-content">
                        <table class="result-tab" width="100%">
                            <tr>
                                <th>选择</th>
                                <th>序号</th>
                                <th>省</th>
                                <th>市</th>
                                <th>县/区</th>
                                <th>学校</th>
                                <th>年级</th>
                                <th>班级</th>
                                <th>姓名</th>
                                <th>编号</th>
                                <th>学号</th>
                                <th>电话</th>
                                <th>类型（老师/家长/学生）</th>
                                <th>级别（小/初/高）</th>
                                <th {if condition="$articleid neq ''"}style="display:none;"{/if}>编辑</th> 
                            </tr>

                            {volist name="artres" id="vo"}
                            <tr>
                               <td> <input  type="checkbox" name="coffee" value="{$vo.id}">   </td>
                               <td>{$vo.id}</td>
                               <td>{$vo.province}</td>
                               <td>{$vo.city}</td>
                               <td>{$vo.area}</td>
                               <td>{$vo.school}</td>
                               <td>{$vo.grade}</td>
                               <td>{$vo.class}</td>
                               <td>{$vo.name}</td>
                               <td>{$vo.number}</td>
                               <td>{$vo.serialnumber}</td>
                               <td>{$vo.telephone}</td>
                               <td>                                      
                                {if condition="$vo.type eq 1"}老师{/if}
                                {if condition="$vo.type eq 2"}家长{/if}
                                {if condition="$vo.type eq 3"}学生{/if}
                            </td>
                            <td>
                                {if condition="$vo.level eq 1"}小学{/if}
                                {if condition="$vo.level eq 2"}初中{/if}
                                {if condition="$vo.level eq 3"}高中{/if}
                            </td>


                            <!-- <td><a href="index/artid/6.html">{$vo.id}</a></td>
                            <td>
                                {if condition="$vo['pic'] neq '' "}
                                <img height="50" src="__PUBLIC__{$vo.pic}">
                                {else /}
                                暂无缩略图
                                {/if}
                            </td>
                            <td>{$vo.name}</td>
                            <td>{$vo.name}</td>
                            <td>{$vo.time|date="Y-m-d",###}</td>
                            <td>{$vo.time|date="Y-m-d",###}</td>  -->
                            <td {if condition="$articleid neq ''"}style="display:none;"{/if}>
                                <a class="link-update" href="{:url('edit',array('id'=>$vo['id']))}">修改</a>
                                <a class="link-del" onclick="return confirm('你确定要删除该用户吗？');" href="{:url('del',array('id'=>$vo['id']))}">删除</a>
                            </td>
                        </tr>
                        {/volist}
                    </table>
                    <div>
                        <br />
                        <button class="btn"  onclick="checkedAll()"  type="button" id="btnSelectall"  >全选</button>
                        {if condition="$articleid eq ''"} 
                        <button class="btn"  href="dd"  type="button" id="btnSelectall" onclick="createOrder()" >批量删除选中用户</button>
                        {else}
                        <button class="btn"  href="dd"  type="button" id="btnSelectall" onclick="joinlist()" >加入以上选定用户</button> <button class="btn"  href="dd"  type="button" id="btnSelectall" onclick="joinlistclear()" >重置</button>
                        <!-- <input type="button" onclick="createOrder()" value="批量删除选中"> -->
                        <input  class="form-control" type="text" name="limit" id="order" size="50" value=""  placeholder="指定的用户ID">
                        <input type="hidden" name="articleid" id="order" size="50" value="<?php echo input('articleid') ?>">
                        <select name="type">                                       
                                            <option     value="0">  类型不限  </option>
                                            <option     value="1">  老师  </option>
                                            <option     value="2">  家长  </option>
                                            <option     value="3">  学生  </option>
                                       
                        </select>
                        <button class="btn btn-success" href="dd"  type="submit" id="btnSelectall"  >提交保存</button>  
                        {/if}

                    </div>


                    <script type="text/javascript">

                    //将所有的checkbox全部选中  
                    function checkedAll(){     
                        var objs = document.getElementsByTagName("input");   

                        for(var i =0;i<=objs.length;i++){    
                         var obj = objs[i];    
                         if(obj.type=="checkbox"){    
                            if(i!=100){  

                                obj.checked=true;  

                            }  
                        }    
                    }    
                } 
                 

                document.getElementById("order").value= localStorage.pagecount

                function joinlistclear(){

                    localStorage.pagecount=""
                    document.getElementById("order").value= ""
                }
                function joinlist()
                {
                    coffee=document.forms[0].coffee
                    txt=""
                    for (i=0;i<coffee.length;++ i)
                    {
                        if (coffee[i].checked)
                        {
                            txt=txt + coffee[i].value + ","
                        }
                    }
                    if (txt) {

                       //  if(window.localStorage){
                       //     alert('This browser supports localStorage');
                       // }else{
                       //     alert('This browser does NOT support localStorage');
                       // }

                      //   if (localStorage.pagecount)
                      //   {
                      //     localStorage.pagecount=Number(localStorage.pagecount) +1;
                      // }
                      // else
                      // {
                      //     localStorage.pagecount=1;
                      // }

                     // 去除重复选择问题的代码 开始
                      var astr = txt;
                        var bstr = localStorage.pagecount; 

                        var s = "," + astr + ","
                        var a  = bstr.split(",");
                        for(var i=0;i<a.length;i++){
                           if(s.indexOf(","+ a[i] +",")==-1){
                              s += a[i] + ",";
                           }    
                        }
                        s = s.substr(1,s.length-2);
                        //alert(s)
                        // 去除重复选择问题的代码 结束

                      localStorage.pagecount = s

                      var gmt = s

                          //window.location.href="{:url('del11',array('id'=>1))}" + "/alldel/"+txt;
                      //document.getElementById("order").value="您指定投票的用户有11： " + txt
                      
                        // <?php echo session('name', 'thinkphp');?>
                        // $a = "199"
                        // $b = "<?php echo session('name', '"
                        // $c = "');?>"
                        // $d = $b + $a +$c

                         
                      document.getElementById("order").value= gmt
                    }
                }
                 
                function createOrder()
                {
                        coffee=document.forms[0].coffee
                        txt=""
                        for (i=0;i<coffee.length;++ i)
                        {
                            if (coffee[i].checked)
                            {
                                txt=txt + coffee[i].value + ","
                            }
                        }
                        if (txt) {
                            var r=confirm("确定要删除吗？!");
                            if (r==true)
                            {
                              window.location.href="{:url('del',array('id'=>1))}" + "/alldel/"+txt;
                          }
                          else
                          {
                              // alert("You pressed Cancel!");
                          }

                      }
                      else
                      {
                        alert("未选择");
                            // document.getElementById("order").value="您订购的咖啡带有： " + txt
                        }
                    }


                    </script>

                    <div class="list-page">{$artres->render()}</div>
                </div>
            </form>
        </div>
    </div>
    <!--/main-->
</div>
</body>









